
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 2684
 * @Author : WangRuoyu 
 * @Date : 2023/5/31 9:26
 */
#include "iostream"
#include "vector"

using namespace std;

class Solution {
public:
    int maxMoves(vector<vector<int>> &grid) {
        int f[grid.size()][grid[0].size()];
        int res = 0;
        for (int j = 0; j < grid[0].size(); ++j) {
            for (int i = 0; i < grid.size(); ++i) {
                f[i][j] = 0;
                if (j > 0) {
                    if (i > 0 && grid[i - 1][j - 1] < grid[i][j]) f[i][j] = max(f[i][j], f[i - 1][j - 1] + 1);
                    if (grid[i][j - 1] < grid[i][j]) f[i][j] = max(f[i][j], f[i][j - 1] + 1);
                    if (i < grid.size() - 1 && grid[i + 1][j - 1] < grid[i][j])
                        f[i][j] = max(f[i][j], f[i + 1][j - 1] + 1);
                    if (!f[i][j]) f[i][j] = -1000000;
                }
                res = max(res, f[i][j]);
            }
        }
        return res;
    }
};


int main() {
    Solution sl;

    return 0;
}